import { CozeAPI } from '@coze/api';

// coze token，需要每月更新
const cozeToken =
  'pat_NuATZ5hsIrlIVsS4zWjj8afLJsWoJthmR5hIYVjXnph72TtzimUKr0tl2Mnp82Kt';

export const apiClient = new CozeAPI({
  token: cozeToken,
  baseURL: 'https://api.coze.cn',
  allowPersonalAccessTokenInBrowser: true,
});

// coze搜索相关文档工作流ID
const searchWorkflowId = '7484547449727418402';

export const searchDocForCoze = (question: string) => {
  const stream = apiClient.workflows.runs.stream({
    workflow_id: searchWorkflowId,
    parameters: {
      USER_INPUT: question,
    },
  });
  return stream;
};
